from clientUtil import *



# 创建InfluxDB客户端
client = devClient()

# 写入数据
# data = [
#     {
#         'measurement': 'cpu_usage',
#         'fields': {'value': -0.5}
#     }
# ]
# client.write_points(data)

# 查询数据
# query = " SHOW SERIES CARDINALITY FROM ActValWbl4 "
# query = " select * from ActValWbl1 where equipmentAcode = '虚拟设备4'  and time >= '2025-04-14T00:00:00.000000Z'  and time <= '2025-04-14T17:44:15.000000Z' "
query = " SHOW SERIES FROM ActValWbl1 where equipmentAcode = '虚拟设备4'  and time >= '2025-04-14T00:00:00.000000Z'  and time <= '2025-04-14T17:44:15.000000Z' "
result = client.query(query)
# 获取查询结果的列表数据
data_list = list(result.get_points())
print(len(data_list))

# 循环迭代列表数据
for index,data in enumerate(data_list):
    # 循环键值对
    for index,(key, value) in enumerate(data.items()):
        print(f"索引值：{index}, 键：{key}, 值：{value}")


# 关闭客户端
client.close()